const fs = require('fs')
const path = require('path')

const dotenv = require('dotenv')

// 当调用 config 方法后，process.env 中便多了 .env 文件中定义的常量属性
dotenv.config()

// fs模块中的相对路径是相对于 process.cwd() 而言的！
const PRIVATE_KEY = fs.readFileSync(
	path.resolve(__dirname, './keys/private.key')
)
const PUBLIC_KEY = fs.readFileSync(path.resolve(__dirname, './keys/public.key'))

// 微信登录鉴权
const APP_ID = 'wx8387b59e3de92d34'
const APP_SECRET = '32c9dd862b60a3861cc74bb9fea187bb'

// console.log('process.env: ---', process.env)

// 这里先解构，然后再导出
module.exports = {
	SERVER_HOST,
	SERVER_PORT,
	MYSQL_HOST,
	MYSQL_PORT,
	MYSQL_DATABASE,
	MYSQL_USER,
	MYSQL_PASSWORD,

} = process.env

module.exports.PRIVATE_KEY = PRIVATE_KEY
module.exports.PUBLIC_KEY = PUBLIC_KEY
module.exports.APP_ID = APP_ID
module.exports.APP_SECRET = APP_SECRET
